<template>
	<view>
		<!-- 	<view class="new-head" :style="{'margin-top':StatusBarHeight+10+'rpx',}">
			<image src="@/static/home/arrow-left.png" mode="aspectFill" @click="back"
				style="width: 48rpx;height: 48rpx;">
			</image>

			<view class="new-submit" @click="onsubmit">
				提交
			</view>
		</view> -->

		<view class="centent">
			<view class="centent-title">
				请选择举报理由
			</view>
			<view class="container">
				<view v-for="(item, index) in options" :key="index" class="radio-item"
					:class="{ 'active': selectedIndex === index }" @tap="selectOption(index)">
					{{ item }}
				</view>
			</view>
		</view>

		<view class="new-submit" @click="onsubmit">
			提交
		</view>
	</view>
</template>

<script>
	import {
		getStatusBarHeight,
	} from "@/utils/system.js"
	import {
		mapState,
		mapMutations
	} from "vuex";
	import {
		queryWaring,
		reportSave
	} from '@/api/apis.js';
	export default {
		data() {
			return {
				StatusBarHeight: 0, //高度
				options: [],
				// 当前选中的索引  
				selectedIndex: 0,
				postRemarkId: null, // 评论/帖子id
				reportType: null, //举报类型 0 帖子 1评论
			};
		},
		computed: {
			...mapState("userInfo", ["Info", 'storeId']),
		},
		mounted() {
			this.StatusBarHeight = getStatusBarHeight()
			this.onSearch()

		},
		onLoad(e) {
			console.log(e);
			this.postRemarkId = e.id
			this.reportType = e.Type
		},

		methods: {
			back() {
				uni.navigateBack(0)
			},

			onSearch() {
				queryWaring({}).then(res => {
					this.options = res.result
				})
			},

			// 选择选项  
			selectOption(index) {
				this.selectedIndex = index;
			},

			// 提交举报
			onsubmit() {
				console.log(this.Info);
				let params = {
					"customerId": this.Info.id,
					"nickName": this.Info.nickName,
					"postRemarkId": this.postRemarkId,
					"reportReason": this.options[this.selectedIndex],
					"reportType": this.reportType

				}
				reportSave(params).then(res => {
					if (res.success) {
						uni.showToast({
							position: "center",
							icon: "success",
							title: '举报成功',
							duration: 2000
						});
						setTimeout(() => {
							this.back()
						}, 2000)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	// .new-head {
	// 	height: 92rpx;
	// 	width: 100%;
	// 	display: flex;
	// 	justify-content: space-between;
	// 	padding: 34rpx 32rpx 18rpx 40rpx;

	// 	.new-submit {
	// 		width: 104rpx;
	// 		height: 52rpx;
	// 		background: linear-gradient(270deg, #FD702B 0%, #FF2828 100%);
	// 		border-radius: 8rpx;
	// 		font-family: PingFang SC, PingFang SC;
	// 		font-weight: 400;
	// 		font-size: 28rpx;
	// 		color: #FFFFFF;
	// 		text-align: left;
	// 		font-style: normal;
	// 		text-transform: none;

	// 		display: flex;
	// 		align-items: center;
	// 		justify-content: center;
	// 	}
	// }

	.centent {
		box-sizing: border-box;
		width: 750rpx;
		height: 424rpx;
		padding: 24rpx 32rpx 32rpx 32rpx;
		background: #FFFFFF;
		border-radius: 0px;

		.centent-title {
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 28rpx;
			color: #333333;
			line-height: 44rpx;
			text-align: left;
			font-style: normal;
			text-transform: none;
			margin-bottom: 32rpx;
		}

		.container {
			display: flex;
			flex-wrap: wrap;
		}

		.radio-item {
			// padding: 10px;
			// margin-bottom: 10px;
			// border: 1px solid #ccc;
			// /* 边框可选 */
			// border-radius: 5px;
			// cursor: pointer;

			width: 48%;
			height: 64rpx;
			background: #F7F7F9;
			border-radius: 32rpx;
			display: flex;
			font-size: 28rpx;
			align-items: center;
			justify-content: center;
			margin-bottom: 24rpx;
		}

		.radio-item:nth-child(odd) {
			margin-right: 4%;
		}

		.radio-item.active {
			background: #FEE9E7;
			font-weight: 400;
			font-size: 28rpx;
			color: $uni-text-color-red;
		}

	}

	.new-submit {
		position: fixed;
		bottom: 60rpx;
		left: calc(50% - 343rpx);
		width: 686rpx;
		height: 72rpx;
		background: $uni-color-theme;
		border-radius: 36rpx;
		display: flex;
		justify-content: center;
		align-items: center;

		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #FFFFFF;
	}
</style>